{% extends "home/common/layout.html" %}

{% block content %}
<section class="content">
    <div class="page-header">
        <h3>{{ config['APP_NAME'] }}</h3>
        <h4>{{ config['APP_NAME'] }} 用于管理和调度企业的定时任务，并对异常的任务进行提醒报警。报警方式支持：企业微信和钉钉</h4>
    </div>
    <div class="row">
        <div class="col-md-12 col-lg-12 col-sm-12">
            <div class="box box-solid">
                <div class="box-header with-border">
                    <h3 class="box-title">Job统计</h3>
                </div>
                <div class="box-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12 col-lg-12">
                            <div class="col-md-4 col-lg-4 col-xs-12">
                                <a href="{{ GlobalUrlService.buildHomeUrl('/job/index/index') }}?owner_uid=0" class="small-box bg-yellow">
                                    <div class="inner">
                                        <h1>Job总数</h1>
                                        <h2>{{ job_count }}</h2>
                                    </div>
                                    <div class="icon">
                                        <i class="fa fa-bar-chart"></i>
                                    </div>
                                </a>
                            </div>

                            <div class="col-md-4 col-lg-4 col-xs-12">
                                <a href="{{ GlobalUrlService.buildHomeUrl('/job/server/index') }}" class="small-box bg-yellow">
                                    <div class="inner">
                                        <h1>服务器总数</h1>
                                        <h2>{{ server_count }}</h2>
                                    </div>
                                    <div class="icon">
                                        <i class="fa fa-bar-chart"></i>
                                    </div>
                                </a>
                            </div>

                            <div class="col-md-4 col-lg-4 col-xs-12">
                                <a href="{{ GlobalUrlService.buildHomeUrl('/job/tools/alert') }}" class="small-box bg-yellow">
                                    <div class="inner">
                                        <h1>今日报警</h1>
                                        <h2>{{ alert_count }}</h2>
                                    </div>
                                    <div class="icon">
                                        <i class="fa fa-bar-chart"></i>
                                    </div>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-12 col-lg-12 col-sm-12">
            <div class="box box-solid">
                <div class="box-header with-border">
                    <h3 class="box-title">运行类型统计</h3>
                </div>
                <div class="box-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12 col-lg-12">
                            {% for _job_type_id,_job_type_title in job_type_map.items() %}
                            <div class="col-md-4 col-lg-4 col-xs-12">
                                <a href="{{ GlobalUrlService.buildHomeUrl('/job/index/index') }}?owner_uid=0&job_type={{_job_type_id}}" class="small-box bg-yellow">
                                    <div class="inner">
                                        <h1>{{ _job_type_title }}</h1>
                                        <h2>
                                            {% if _job_type_id  in type_job_map %}
                                                {{ type_job_map[_job_type_id] }}
                                            {% else %}
                                                0
                                            {% endif %}
                                        </h2>
                                    </div>
                                    <div class="icon">
                                        <i class="fa fa-bar-chart"></i>
                                    </div>
                                </a>
                            </div>
                            {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-12 col-lg-12 col-sm-12">
            <div class="box box-solid">
                <div class="box-header with-border">
                    <h3 class="box-title">分类统计</h3>
                </div>
                <div class="box-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12 col-lg-12">
                            {% for _cate_id,_cate_item in cate_map.items() %}
                            <div class="col-md-4 col-lg-4 col-xs-12">
                                <a href="{{ GlobalUrlService.buildHomeUrl('/job/index/index') }}?owner_uid=0&cate_id={{_cate_id}}" class="small-box bg-yellow">
                                    <div class="inner">
                                        <h1>{{ _cate_item['name'] }}</h1>
                                        <h2>
                                            {% if _cate_id  in cat_job_map %}
                                                {{ cat_job_map[_cate_id] }}
                                            {% else %}
                                                0
                                            {% endif %}
                                        </h2>
                                    </div>
                                    <div class="icon">
                                        <i class="fa fa-bar-chart"></i>
                                    </div>
                                </a>
                            </div>
                            {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        使用手册
                    </h3>
                </div>
                <div class="panel-body">
                    <ul>
                        <li> 基础支撑：Linux、python3、Flask、MySQL</li>
                        <li> 在Job管理 -> 服务器 添加服务器信息</li>
                        <li> 在对应的服务器注册服务，执行如下命令 <code>python manage_job.py runjob -m worker -a reg -p ${server_id} </code> 其中${server_id}是第一步中添加服务器信息的ID</li>
                        <li> 详细使用手册：<a target="_blank" href="http://dcenter.jixuejima.cn/#/flask/jobs/readme">http://dcenter.jixuejima.cn/#/flask/jobs/readme</a></li>
                        <li> 本系统基于 Flask CMS V2开发，详细手册：<a target="_blank" href="http://dcenter.jixuejima.cn/#/flask/v2/readme">http://dcenter.jixuejima.cn/#/flask/v2/readme</a> </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</section>
{% endblock %}

